package leetcode.array;

import java.util.Arrays;

/**
 * @author Cheng Jun
 * Description: 根据麻将规则 判断是否 和牌
 * @version 1.0
 * @date 2022/1/24 16:05
 */

// todo 未完待续
public class mahjong {
    public static void main(String[] args) {
        System.out.println(mahjong("11123456789987"));
    }

    // static boolean HUPAI = false;

    public static boolean mahjong(String cards) {
        // 转换成 排序数组
        // 判断是否存在 单牌
        // dfs
        char[] cardArr = cards.toCharArray();
        Arrays.sort(cardArr);
        return false;
    }

    // true: 不存在单牌
    // false: 存在单牌
    private static boolean canDfs(char[] cardArr) {
        boolean res = true;
        for (int i = 0; i < cardArr.length; i++) {
            boolean flag = false;
            if (i - 1 >= 0) {
                flag = cardArr[i - 1] == cardArr[i] || (cardArr[i - 1] + 1 == cardArr[i]);
                if (flag) continue;
            }
            if (i + 1 < cardArr.length) {
                flag = cardArr[i] == cardArr[i + 1] || (cardArr[i] + 1 == cardArr[i + 1]);
                if (flag) continue;
            }
            res = res && flag;
        }
        return res;
    }

    private static void dfs(char[] cardArr, int tripleNum, boolean[] used) {
        if (tripleNum == 4) {

        }
        // 构造 triple
        // used 赋值
        // dfs
        // used 反向操作


    }
}
